/*
 * tick-ss805x.c
 *
 * Tick driver for SS805X.
 *
 * Copyright (C) 2024 Sinh Micro, Inc.
 * Subject to the GNU Public License, version 1.
 *
 * Author: lixiang<lixiang@sinhmicro.com>
 * 
 * Encoding format: GB2312
 * Version: v1.2.2
 * Date: 2024-11-05
 */

#include "hal-config.h"
#include "hal-regs.h"
#include "types.h"
#include "tick.h"

#if (CONFIG_USING_TICK == 1 && (defined(CONFIG_SYS_CHIP_SERIES_SS805X)))

#define TICKS_10MS          (1)
#define TICKS_100MS         (10)

static uint8_t tick_cnt;

bit_t tick_expired_10;
bit_t tick_expired_100;

void systick_ISR(void) INTERRUPT 14
{
    tick_expired_10 = 1;

    tick_cnt++;
    if (tick_cnt == TICKS_100MS) {
        tick_cnt = 0;
        tick_expired_100 = 1;
    }

    TICKCON |= 0x10;
}

#endif
